package edu.siu.math.egut.main;

import java.util.WeakHashMap;

public class TestWeakHashMap {
    public static void main(String[] args) {
     WeakHashMap map=new WeakHashMap();

      String s1=new String("java");
      map.put(s1, "good");
      System.out.println(map.size());
     
      
      String s2=new String("java");
      map.put(s2,"ok");
      System.out.println(map.size());

    //Since s1.equals(s2) is true and hash is same, the earlier value
    //against key s1 ("good") in the map is replaced by the new one. ("ok")

      s1=null;

      System.gc();
      //Verify Full GC with the -verbose:gc option

     System.out.println(map.size());
   }
  }
